﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace calculadora
{
    
    public partial class Form1 : Form
    {
        public OP op;
        Double result;
        public Form1()
        {
            InitializeComponent();
        }

        void add(String text)
        {
            textBox1.Text += ' '+text;
        }

        void resultado() {
            op.b = Double.Parse(textBox2.Text);
            add(textBox2.Text);
            textBox2.Text = op.result().ToString();
            result = op.result();
            op = null;
        }
        private void button22_Click(object sender, EventArgs e)
        {
            
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (op == null)
            {
                op = new Adicao();
                op.a = Double.Parse(textBox2.Text);
                add(textBox2.Text + " + ");
            }
            else {
                resultado();
            }
           
        }

       

        private void button3_Click(object sender, EventArgs e)
        {
            textBox2.Text = (new Pi()).result().ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            add("seno("+textBox2.Text+")");
            textBox2.Text = (new Seno(double.Parse(textBox2.Text))).result().ToString();
        }

        private void button29_Click(object sender, EventArgs e)
        {
            Double a = Double.Parse(textBox1.Text);
            Double b = Double.Parse(textBox2.Text);
            richTextBox1.Text += "x + y = "+ (new Adicao(a, b)).result().ToString() + "\r";
            richTextBox1.Text += "x - y = " + (new Subtracao(a, b)).result().ToString() + "\r";
            richTextBox1.Text += "x * y = " + (new Multiplicacao(a, b)).result().ToString() + "\r";
            richTextBox1.Text += "x * y = " + (new Divisao(a, b)).result().ToString() + "\r";
            richTextBox1.Text += "COS(x) = " + (new Coseno(a)).result().ToString() + "\r";
            richTextBox1.Text += "SEN(x) = " + (new Seno(a)).result().ToString() + "\r";
            richTextBox1.Text += "TAN(x) = " + (new Tangente(a)).result().ToString() + "\r";
            richTextBox1.Text += "y^x = " + (new XY(a,b)).result().ToString() + "\r";
            richTextBox1.Text += "10^x = " + (new DezX(a)).result().ToString() + "\r";
            richTextBox1.Text += "x^2 = " + (new XQuadrado(a)).result().ToString() + "\r";
            richTextBox1.Text += "x^3 = " + (new XCubo(a)).result().ToString() + "\r";
            richTextBox1.Text += "RaizQuadrada(x) = " + (new raiz(a)).result().ToString() + "\r";
            richTextBox1.Text += "LOG(x) = " + (new Log(a)).result().ToString() + "\r";
            richTextBox1.Text += "n! = " + (new Fatorial(a)).result().ToString() + "\r";
            richTextBox1.Text += "PI = " + (new Pi()).result().ToString() + "\r";
            richTextBox1.Text += "EXP(x) = " + (new Exponencial(a)).result().ToString() + "\r";




        }

        private void button25_Click(object sender, EventArgs e)
        {
            add("0");
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
